<?php
/**
 *
 * 通用日志记录类
 *
 * @author liang<lang@vip.deyi.com>
 * @since   2015年5月21日
 * @copyright  deyi.com
 */

namespace Apps\Common\Logger;

use Apps\Common\Constant\TaskConstant;
use Apps\Common\Service\TaskService;

/**
 * Class FileLogger
 * @package Apps\Common\Logger
 */
class FileLogger extends \Phalcon\Logger\Adapter\File
{

    private $switch = true;

    public function setSwitch($switch)
    {
        $this->switch = $switch;
    }

    public function debug($message, array $context = null)
    {
        if ($this->switch) {
            parent::debug($message, $context);
        }
    }

    public function error($message, array $context = null)
    {
        // error日志不受日志控制影响
        parent::error($message, $context);
    }

    public function info($message, array $context = null)
    {
        // info日志不受日志控制影响
        parent::info($message, $context);
    }

    public function notice($message, array $context = null)
    {
        if ($this->switch) {
            parent::notice($message, $context);
        }
    }

    public function warning($message, array $context = null)
    {
        parent::warning($message, $context);
    }

    public function alert($message, array $context = null)
    {
        if ($this->switch) {
            parent::alert($message, $context);
        }
    }
}
